package com.cloudsigns.factorymanager2.project.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.GridView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.BaseActivity;
import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.cusenum.CommonEnum;
import com.cloudsigns.factorymanager2.engineering.adapter.GridAdapter;
import com.cloudsigns.factorymanager2.project.bean.SurveyFeedBackForSizeBean;

import java.util.ArrayList;
import java.util.List;

public class SurveyFeedBackForSizeDetailsActivity extends BaseActivity {
    private RelativeLayout rl_back;
    private TextView tv_title;
    private TextView edt_survey_content, edt_survey_size;
    private GridView gridView;
    private TextView btn_delete;

    private List<SurveyFeedBackForSizeBean> datas = new ArrayList<SurveyFeedBackForSizeBean>();
    private int position;

    @Override
    protected void onBaseCreate(Bundle savedInstanceState) {
        setContentView(R.layout.layout_survey_feedback_for_size_details);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        rl_back = findViewById(R.id.rl_back);
        tv_title = findViewById(R.id.tv_title);
        edt_survey_content = findViewById(R.id.edt_survey_content);
        edt_survey_size = findViewById(R.id.edt_survey_size);
        gridView = findViewById(R.id.gridView);
        btn_delete = findViewById(R.id.btn_delete);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        tv_title.setText(getResources().getString(R.string.record_information));

        Intent intent = getIntent();
        position = intent.getIntExtra("position", 0);
        String content = intent.getStringExtra("content");
        int width = intent.getIntExtra("width", 0);
        int hight = intent.getIntExtra("hight", 0);
        int corner = intent.getIntExtra("corner", 0);
        int hightDif = intent.getIntExtra("hightDif", 0);
        int specialWidth = intent.getIntExtra("specialWidth", 0);
        int specialHight = intent.getIntExtra("specialHight", 0);
        int arcLength = intent.getIntExtra("arcLength", 0);
        int arcHight = intent.getIntExtra("arcHight", 0);
        CommonEnum.SurveySizeType surveySizeType = (CommonEnum.SurveySizeType) intent.getSerializableExtra("surveySizeType");

        List<String> imgUrlList = new ArrayList<String>();
        imgUrlList = getIntent().getStringArrayListExtra("imgUrlList");

        edt_survey_content.setText(content);
        if (null != surveySizeType) {
            if (surveySizeType == CommonEnum.SurveySizeType.normal) {
                edt_survey_size.setText("宽" + width + "/高" + hight + "/转角" + corner + "/高差" + hightDif);
            } else if (surveySizeType == CommonEnum.SurveySizeType.special) {
                edt_survey_size.setText("宽" + specialWidth + "/高" + specialHight + "/弧长" + arcLength + "/弧高" + arcHight);
            }
        }

        if (null != imgUrlList && imgUrlList.size() > 0) {
            gridView.setNumColumns(3);
            GridAdapter gridAdapter = new GridAdapter(this);
            gridAdapter.setData(imgUrlList);
            gridView.setAdapter(gridAdapter);
        }
    }

    @Override
    public void setListener() {
        rl_back.setOnClickListener(this);
        btn_delete.setOnClickListener(this);
    }

    @Override
    public void widgetClick(View view) {
        switch (view.getId()) {
            case R.id.rl_back:
                finish();
                break;
            // 删除
            case R.id.btn_delete:
                break;
        }
    }
}
